package com.note.chh.notebook.Adapter;

import android.net.Uri;
import android.support.annotation.LayoutRes;
import android.text.format.Formatter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.note.chh.notebook.R;
import com.note.chh.notebook.Uitls.localFile.bean.VideoItem;

import java.io.File;

/**
 * Created by caihuahui on 2018/1/25.
 */

public class VideoAdapter extends BaseQuickAdapter<VideoItem,BaseViewHolder> {


    public VideoAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, VideoItem item) {
        helper.setText(R.id.tv_title,item.getName());                                   // 显示视频标题
        helper.setText(R.id.tv_size,Formatter.formatFileSize(mContext, item.getSize()));    // 显示视频大小
//        helper.setText(R.id.tv_duration, AppUtil.formatMillis(item.getDuration()));           // 显示视频时间
        helper.setImageResource(R.id.iv_image,R.mipmap.mobile_video_default_icon);
        ImageView imgView = (ImageView) helper.getView(R.id.iv_image);
        Glide.with( mContext )
                .load( Uri.fromFile( new File( item.getPath() ) ) )
                .into( imgView );
    }
}
